package voxietest1.jam;

public class Player {
	public float x;
	public float y;
	public float z;
	public float width;
	public float height;
	
	public float vx = 0;
	public float vy = 0;
	public float vz = .1f;
	
	public Player(float xx, float yy, float zz) {
		x = xx;
		y = yy;
		z = zz;
		width = .5f;
		height = .5f;
	}
	
	public void setVelocity(float velx, float vely, float velz) {
		vx = velx;
		vy = vely;
		vz = velz;
	}
	
	public void Update(float deltaTime) {
		x += vx*deltaTime;
		y += vy*deltaTime;
		z += vz*deltaTime;
		
		float xmin = -1;
		float ymin = -1;
		float xmax = 1;
		float ymax = 1;
		float zmin = -.61f;
		float zmax = .61f;
		
		if (z < zmin) {
			z = zmin;
			vz = -vz;
		}
		
		if (z > zmax) {
			z = zmax;
			vz = -vz;
		}
		
		if (x-width/2 < xmin) {
			x = xmin+width/2;
			vx = -vx;
		}
		if (x+width/2 > xmax) {
			x = xmax-width/2;
			vx = -vx;
		}
		if (y-height/2 < ymin) {
			y = ymin+height/2;
			vy = -vy;
		}
		if (y+height/2 > ymax) {
			y = ymax-height/2;
			vy = -vy;
		}
		
	}
}
